
<%@page import="br.com.fatecpg.ads.poo.projeto.conexao.OracleConnector"%>
<%@page import="java.util.ArrayList"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <link rel="stylesheet" type="text/css" href="_res/css/bootstrap.css">
        <link rel="stylesheet" type="text/css" href="_res/css/bootstrap-theme.css">
        <link rel="stylesheet" type="text/css" href="_res/css/bootstrap.min.css">
        <link rel="stylesheet" type="text/css" href="_res/estilos/estiloPagina.css">
        <link rel="stylesheet" type="text/javascript" href="_res/js/bootstrap.js">
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

        <title>Webutecos</title>
    </head>
    <body>
        <%if (request.getParameter("loginUserName") != null) {

                String user = request.getParameter("loginUserName");
                String pass = request.getParameter("loginPassword");
                String SQL = "SELECT ic_bar FROM USUARIO WHERE nm_usuario ='" + user + "' AND nm_senha='" + pass + "'";
                ArrayList<Object[]> usuario = OracleConnector.getQuery(SQL);
                if (usuario.size() > 0) {
                    session.setAttribute("loginUserName", request.getParameter("loginUserName"));
                    if (usuario.get(0)[0].equals("S")) {
                        session.setAttribute("bar", "S");
                    }
                    response.sendRedirect("pages/home.jsp");
                } else {
                    out.println("<span style='color:red;'>Usuário e/ou senha inválido(s)!</span>");
                }
            } else if (request.getParameter("logoff") != null) {
                session.removeAttribute("loginUserName");
                response.sendRedirect(request.getContextPath());
            }%>
        <div id='divTop'>
            <img src="_res/images/logo.png">
        </div>
        <div id="divCentralizada">
            <form>
                Usuário: <input class="form-control" type="text" name="loginUserName"/>
                Senha: <input  class="form-control" type="password" name="loginPassword"/>
                <input class="btn btn-default" type="submit" value="Entrar"/>
                <a href="pages/cadastro.jsp">Cadastre-se</a>
            </form>
        </div>
        <%@include file="_templates/footer.jsp" %>
    </body>
</html>
